package com.act.service.impl;

import com.act.dao.IAttendanceManagementDao;
import com.act.domain.AttendanceManagement;
import com.act.dto.PagerDTO;
import com.act.service.api.IAttendanceManagementService;
import com.act.vo.PagerVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Random;

@Service
public class AttendanceManagementServiceImpl implements IAttendanceManagementService{
	@Resource
	IAttendanceManagementDao iAttendanceManagementDao;

	@Override
	public void add(AttendanceManagement attendanceManagement) {
		// TODO Auto-generated method stub
		 iAttendanceManagementDao.add(attendanceManagement);
	}

	public void delete(int id) {
		// TODO Auto-generated method stub
		iAttendanceManagementDao.delete(id);
	}
	
	public PagerVo<Map>  getAllList(@Param("pagerDTO")  PagerDTO pagerDTO){
		int startIndex=pagerDTO.getStartIndex();
		int endIndex=pagerDTO.getEndIndex();
		List<Map> list = iAttendanceManagementDao.getAllList(startIndex,endIndex);

		int totalCounts = iAttendanceManagementDao.getCounts();
		PagerVo<Map> pager = new PagerVo<>(pagerDTO.getPageIndex(), pagerDTO.getPageSize(), totalCounts, list);
		return pager;
	};

	//根据员工id和月份查询一个人在这个月内迟到 准时 出差的次数 例子
	public List<Map> getConStatusByEidAndMonth(@Param("empId")int empId, @Param("month")int month){
		return iAttendanceManagementDao.getConStatusByEidAndMonth(empId,month);
	}
	//根据日期或者包括名字查询考勤记录
	public List<AttendanceManagement> getAttendanceByDateTimeOrName(@Param("year")int year,@Param("month")int month,@Param("jobnum")String jobnum){
		return iAttendanceManagementDao.getAttendanceByDateTimeOrName(year,month,jobnum);
	}

	//查总记录数
	public int getCounts() {
		return iAttendanceManagementDao.getCounts();

	}

	@Override
	public List<AttendanceManagement> getByJobnumInMonth(String jobnum) {
		return iAttendanceManagementDao.getByJobnumInMonth(jobnum);
	}

}
